<template>
	<view class="content">
		<view v-if="lists.length === 0" class="header-box">
			<view class="title">cloudMockjs</view>
			<view class="sub-title">前端开发利器，模拟真实接口请求，快速数据返回</view>
		</view>
		<template v-else>
			<view class="header">
				全部项目
			</view>
			<view class="content-box">
				<template v-for="item in lists">
					<view class="content-item">
						<uni-card isShadow :title="item.project_name" :key="item._id" :extra="item.project_base_path"
							note="Tips">
							{{item.comment?item.comment:'当前项目没有任何描述'}}
							<template v-slot:footer>
								<view class="footer-box">
									<view class="button look">查看</view>
									<view class="button edit">编辑</view>
									<view class="button del">删除</view>
								</view>
							</template>
						</uni-card>
					</view>
				</template>

			</view>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lists: []
			}
		},
		onLoad() {
			uni.$on('add-project',(data)=>{
				// console.log(data);
				this.lists.push(data)
			})
			this.getProject()
		},
		methods: {
			getProject() {
				this.loading = true
				this.$api.get_project().then(res => {
					this.lists = res.lists
				}).catch(err => {
					this.loading = false
					console.log(err);
				})
			},
		}
	}
</script>

<style lang="scss">
	.content {
		flex-shrink: 0;
		// display: flex;
		// flex-direction: column;
		// align-items: center;
		// justify-content: center;
		// height: calc(100vh - 55px);
		// padding: 0 10px;
		// padding-bottom: 10px;
		box-sizing: border-box;
		overflow: hidden;
		background-color: #fff;

		.header {
			font-size: 20px;
			font-weight: 600;
			padding-left: 30px;
			margin-top: 30px;
		}

		.header-box {
			margin-top: 100px;
			text-align: center;
			.title {
				// margin-top: -200px;
				font-size: 40px;
				font-weight: blod;
			}

			.sub-title {
				margin-top: 30px;
				font-size: 16px;
				color: #999;
			}
		}

		.content-box {
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			box-sizing: border-box;
			padding: 15px;
			padding-top: 10px;
			width: 100%;

			.content-item {
				width: 300px;
				flex-shrink: 0;
				box-sizing: border-box;

				.footer-box {
					display: flex;
					justify-content: space-between;
					font-size: 14px;

					// text-decoration: underline;
					.look {
						color: #3F536E;
					}

					.edit {
						color: #3F536E;
					}

					.del {
						color: #DD524D;
					}

					.button {
						transition: all 0.3s;

						&:hover {
							color: #578CBE;
						}
					}

				}
			}
		}
	}

	.to-link {
		text-decoration: underline;
		color: $uni-color-primary;
		cursor: pointer;

		&:hover {
			color: $uni-color-warning;
		}
	}

	.no-data {
		margin-top: 100px;
		text-align: center;
		font-size: 14px;
		color: #999;

		.no-data-text {
			margin-bottom: 20px;
		}
	}
</style>
